﻿@{
    ViewData["Title"] = "登录";
}
@section css{
    <style>
        .row {
            margin-top: 5px;
        }
    </style>
}
<div class="container">
    <form action="/login" method="post">
        <div class="row">
            <div class="col-md-12">
                <input class="form-control" placeholder="用户名" name="username" type="text" />
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <input class="form-control" placeholder="密码" name="password" type="text" />
            </div>
        </div>
  
        <div class="row">
            <div class="col-md-12">
                <input style="width:80px;" type="text" id="yzm" name="validatecode"/>
                <img id="imgVerify" src="/validatecode" alt="看不清？点击更换" onclick="this.src = this.src + '?'" style="vertical-align:middle;" />
                <button class="btn btn-success">登录</button>
                <br />
                <span id="message"></span>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">

            </div>
        </div>
    </form>
</div>
@section scripts{
    <script>
        $(function () {

            $("#yzm").keyup(function () {
                if ($(this).val().length >= 4) {

                    $.get('/validateyzm', { yzm: $(this).val() }, function (result) {
                        if (result) {
                            $("#message").html("验证码正确");
                            $("#message").attr("style", "color:green");
                        }
                        else {
                            $("#message").html("验证码错误");
                            $("#message").attr("style", "color:red");
                        }

                    })
                }
                else {
                    $("#message").html("");
                }
            });
        })
    </script>

}